﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
public partial class administrator_uc_admin_contact_replyemail : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {            
            if (!string.IsNullOrEmpty(Request.QueryString["itemid"]))
            {
                LoadDataInfo(int.Parse(Request.QueryString["itemid"].ToString().Trim()));               
            }
        }
    }
    private void LoadDataInfo(int ItemID)
    {
        DataTable dt = new BLL.CmsBLL().Contact_ViewItemByID(ItemID);
        if (dt.Rows.Count > 0)
        {            
            txtTo.Text = dt.Rows[0]["Email"].ToString();
            txtTitle.Text = dt.Rows[0]["Title"].ToString();          
        }
        else
            lblMessageView.Text = "Load dữ liệu lỗi!";
    }   
    protected void lbtEditItem_Click(object sender, EventArgs e)
    {
        try
        {
            new CommonBLL().SendMail(txtTo.Text, txtTitle.Text, CKEditorBody.Text);
            lblMessageView.Text = "Gửi thành công!";
        }
        catch
        {
            lblMessageView.Text = "Gửi thất bại";
        }     
    }    
}